<template>
  <el-dialog
    title="从图标库中选择"
    class="choose-icon"
    :append-to-body="true"
    :visible.sync="dialogVisible"
    width="1122px"
    >
    <iframe ref="iframe" v-if="src" :src="src" frameborder="0" style="width: 1122px;height: 520px;"></iframe>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="ok">确 定</el-button>
      <el-button @click="dialogVisible = false">取 消</el-button>
  </span>
  </el-dialog>
</template>

<script>
import RefreshJsessionIdMixins from "@/mixins/refreshJsessionId"
import {
    createNamespacedHelpers
} from "vuex";
const {
    mapState,
    mapMutations
} = createNamespacedHelpers("user");
export default {
  mixins:[RefreshJsessionIdMixins],
  data(){
    return{
      iconName:"",
      dialogVisible:false,
      src:""
    }
  },
  computed: {
    ...mapState([
        "ssoV5Url",
    ])
  },
  methods:{
    open(data){
      this.dialogVisible = true
      this.getDdV5SsoToken();
      this.src =  this.ssoV5Url + encodeURIComponent(`/portal/portalDesigner.do?method=iconLibrary&oprate=chooseOne&styleId=1&showType=1`) 
    },
    ok(){
      if(!this.$refs.iframe.contentWindow || !this.$refs.iframe.contentWindow.$ || !this.$refs.iframe.contentWindow.$("#className").val()){
        this.$message({
          type: 'warning',
          message:'请选择图标!'
        });
      }else{
        this.$emit("choose", this.$refs.iframe.contentWindow.$("#className").val().replace(/^./,''))
        this.dialogVisible = false
      }
    }
  }
}
</script>
<style lang="scss" scoped>
 .choose-icon{
   & /deep/ .el-dialog__body{
     padding: 0;
   }
 }
</style>